<?php
/** Copyright 2014 TinPhp Systems, Inc.
 * @author zhangxilian 2013-8-15
 */
if (!defined('IN_TINPHP')) {
    exit('Access Denied');
}
require_once('adminApp.php');
/** 后台管理首页 */
class IndexController extends AdminAppController {
	
	public function __construct() {
		$this->chkLogin=true;   
        parent::__construct();        
	}
 	
 	public function actionDefault(){
 		//---加载菜单---
		$menuLogic = $this->Logic('MenuLogic');
		$this->getPermission();
		$mainMenus = $menuLogic->getMenuAll('*','STATE=1 AND parent_id=0 AND ID in('.$this->powerArr['menuids'].')','Order by order_num');
		$tpDatas['topmenus'] = $mainMenus;
		
 		T::$tpl->set('datas',$tpDatas);
 	}
 	
 	public function actionLeft(){
 		//T::$tplFile='admin/index/left';
 		$menuid = $_REQUEST['menuid'] ? $_REQUEST['menuid'] : 26;
 		$menulist = null;
 		$powerArr = Auth::getAdminPermission();
 		$cond = 'STATE=1 AND ID in('.$powerArr['menuids'].')';
 		if($menuid && intval($menuid)){	 		
	 		$cond .= ' AND parent_id='.$menuid;
	 		$menulist = $this->Logic('MenuLogic')->getMenuAll('*',$cond,'Order by order_num');
 		}else{
 			$cond .= ' AND is_quick=1 AND parent_id!=0';
	 		$menuRes = $this->Logic('MenuLogic')->getMenuList('*',$cond,'Order by parent_id,order_num', 1, 10, false);
	 		$menulist = $menuRes['data'];
 		}
 		T::$tpl->set('menulist',$menulist);
 	}
 	
 	public function actionRight(){
 		T::$tplFile='admin/index/right';
 	}
 	/** 保存用户设置的皮肤 */
 	public function actionSaveskin(){
 		T::$tplFile='public/empty';
 		if($this->adminInfo!=null){
 			$skinName = trim($_REQUEST['skinname']);
 			try{
 				$this->Logic('AccountLogic')->updateFieldVal("SKIN_NAME", $skinName, "ID=".$this->adminInfo['ID']);
 			}catch(Exception $e){}
 			$this->adminInfo['SKIN_NAME'] = $skinName;
 			Auth::setAdminInfo($this->adminInfo);
 		}
 	}
 	
}//End CLass
?>
